<%@ page import="java.util.Locale" %>
<%@ page import="java.util.ResourceBundle" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    //通过请求头的accept-language 拿到当前浏览器的地区信息
    String localeStr = request.getParameter("locale");
    Locale locale = null;
    if ("en_US".equals(localeStr)) {
        locale = Locale.US;
    } else if ("zh_CN".equals(localeStr)) {
        locale = Locale.CHINA;
    } else {
        locale = request.getLocale();
    }
    //获取资源包
    ResourceBundle i18n = ResourceBundle.getBundle("i18n", locale);
%>
<html>
<head>
    <title><%=new String(i18n.getString("login").getBytes("ISO-8859-1"), "UTF-8")%>
    </title>
</head>
<body>
<a href="login.jsp?locale=zh_CN">中文</a>
<a href="login.jsp?locale=en_US">English</a>
<form method="get">
    <input type="hidden" name="action" value="login">
    <%=new String(i18n.getString("username").getBytes("ISO-8859-1"), "UTF-8") %>:<input name="username"
                                                                                        type="text"/><br>
    <%=new String(i18n.getString("password").getBytes("ISO-8859-1"), "UTF-8")%>:<input name="password" type="text"/><br>
    <button type="submit"><%=new String(i18n.getString("login").getBytes("ISO-8859-1"), "UTF-8")%>
    </button>
</form>
</body>
</html>